package book;
//书架
public class BookList {
    private Book[] book;//数组代表书架
    private int usedSize;//书架书数

    /**
     * 构造方法
     * 数组初始化为10
     * usedSize初始化为0
     */
    public BookList() {
        this.book = new Book[10];
        this.book[0] = new Book("三国演义","罗贯中",24,"小说");
        this.book[1] = new Book("西游记","吴承恩",25,"小说");
        this.book[2] = new Book("红楼梦","曹雪芹",19,"小说");
        this.usedSize = 3;
    }

    /**
     * get and set方法
     * @return
     * get获取书数
     * set更改书数
     */
    public int getUsedSize() {
        return usedSize;
    }

    public void setUsedSize(int usedSize) {
        this.usedSize = usedSize;
    }

    /**
     * getBook->获取书架书
     * @param pos
     * @return
     * 根据下标,找到书架对应的书
     */
    public Book getBook(int pos) {
        return this.book[pos];
    }
    /**
     * setBook->添加图书
     * 添加图书到相应书架下标对应数组位置
     */
    public void setBook(Book book,int pos) {
        this.book[pos] = book;
    }
}
